package com.candy.dao;

import java.util.List;
import java.util.Map;
import java.util.Set;

public class TestDriver {
    public static void main(String[] args) {
        test03();
    }

    /**
     * 添加商品信息
     */
    public static void test03() {
        DBHelper.update("INSERT INTO tb_product(userID,productName,typeID,price,information,productstatus)\n" +
                "VALUES\n" +
                "(2,'苹果手机',1,5999,'215G内存，双核处理器',1)");
    }
    /**
     * 查询商品信息
     * */
    public static void test02() {
       List<Map<String,Object>>  lp= DBHelper.query4ListMap("SELECT * from  tb_product");
        for (Map<String,Object> mp:lp
        ) {
            Set se=mp.keySet();
            for (Object ob:se
            ) {
                System.out.print("列名："+ob+"；值："+mp.get(ob)+"\t");
            }
            System.out.println();
        }


    }

    /**
     * 获取用户订单信息
     */
    public static void test01() {
        List<Map<String,Object>>  lp= DBHelper.query4ListMap("SELECT * FROM \n" +
                "tb_order o \n" +
                "LEFT JOIN tb_product p\n" +
                "ON o.productID=p.productID\n" +
                "WHERE o.userid=1");
        for (Map<String,Object> mp:lp
        ) {
            Set se=mp.keySet();
            for (Object ob:se
            ) {
                System.out.print("列名："+ob+"；值："+mp.get(ob)+"\t");
            }
            System.out.println();
        }

    }


}
